class NewSyringeFire extends SyringeFire;

var float SummaryHeal,InstantPart;

Function Timer()
{
	local SRHumanPawn Healed;
	local float HealSum;

	Healed = SRHumanPawn(CachedHealee);
	CachedHealee = none;
	
	SRHumanPawn(Instigator).ConsumeStamina(0.018);

	if ( Healed != none && Healed.Health > 0 && Healed != Instigator )
	{
        Weapon.ConsumeAmmo(ThisModeNum, AmmoPerFire);

		InstantPart = default.InstantPart;
		HealSum = SummaryHeal - InstantPart;

		if ( KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo) != none && KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo).ClientVeteranSkill != none )
		{
			HealSum *= KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo).ClientVeteranSkill.Static.GetHealPotency(KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo));
			InstantPart *= KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo).ClientVeteranSkill.Static.GetHealPotency(KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo));
		}
		
		Healed.TakeHealing(Instigator.Controller,InstantPart,HealSum,1.35);
		
		// Tell them we're healing them
		PlayerController(Instigator.Controller).Speech('AUTO', 5, "");
		LastHealMessageTime = Level.TimeSeconds;
	}
}

function AttemptHeal()
{
	local KFHumanPawn Healtarget;

    CachedHealee = none;

    if( AllowFire() && CanFindHealee() )
    {
        NewModeDoFire();
        Syringe(Weapon).ClientSuccessfulHeal(CachedHealee.PlayerReplicationInfo.PlayerName);
    }
    else
    {
        // Give the messages if we missed our heal, can't find a target, etc
		if ( KFPlayerController(Instigator.Controller) != none )
		{
			if ( LastHealAttempt + HealAttemptDelay < Level.TimeSeconds)
			{
				PlayerController(Instigator.controller).ClientMessage(NoHealTargetMessage, 'CriticalEvent');
				LastHealAttempt = Level.TimeSeconds;
			}

			if ( Level.TimeSeconds - LastHealMessageTime > HealMessageDelay )
			{
				// if there's a Player within 2 meters who needs healing, say that we're trying to heal them
				foreach Instigator.VisibleCollidingActors(class'KFHumanPawn', Healtarget, 100)
				{
					if ( Healtarget != Instigator && Healtarget.Health < Healtarget.HealthMax )
					{
						PlayerController(Instigator.Controller).Speech('AUTO', 5, "");
						LastHealMessageTime = Level.TimeSeconds;

						break;
					}
				}
			}
		}
    }
}

simulated function SuccessfulHeal()
{
    if( Weapon.Role < Role_Authority )
    {
        NewModeDoFire();
    }
}

function NewModeDoFire()
{
	local float Rec;

	Rec = GetFireSpeed();
	FireRate = default.FireRate/Rec;
	FireAnimRate = default.FireAnimRate*Rec;
	ReloadAnimRate = default.ReloadAnimRate*Rec;
	Load = 0;

	Super(WeaponFire).ModeDoFire();
}

function float GetFireSpeed()
{
	local SRPlayerReplicationInfo SRPRI;
	
	SRPRI = SRPlayerReplicationInfo(Instigator.PlayerReplicationInfo);
	
	return class<SRVeterancy>(SRPRI.ClientVeteranSkill).Static.GetFireModeSpeed(SRPRI,Self.Class);
}

defaultproperties
{
	SummaryHeal = 25
	InstantPart = 6.50
}
